<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>项目详情 </title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="robots" content="all,follow">
    <!-- Bootstrap CSS-->
    <link rel="stylesheet" href="vendor/bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome CSS-->
    <link rel="stylesheet" href="vendor/font-awesome/css/font-awesome.min.css">
    <!-- Fontastic Custom icon font-->
    <link rel="stylesheet" href="css/fontastic.css">
    <!-- Google fonts - Poppins -->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins:300,400,700">
    <!-- theme stylesheet-->
    <link rel="stylesheet" href="css/style.default.css" id="theme-stylesheet">
    <!-- Custom stylesheet - for your changes-->
    <link rel="stylesheet" href="css/custom.css">
    <!-- Favicon-->
    <link rel="shortcut icon" href="img/favicon.ico">
    <!-- Tweaks for older IEs--><!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script><![endif]-->
       <script type="text/javascript" src="js/getUrlParam.js" ></script>
  </head>
  <body>
    <div class="page">
    
      <div class="page-content d-flex align-items-stretch" > 
        <!-- Side Navbar -->
        
        <div class="content-inner" style="width:100%;">
          <!-- Page Header-->
         	<header class="page-header">
            <div class="container-fluid">
              <h2 class="no-margin-bottom"><span class="icon-close "  onclick="history.back()"></span>&nbsp;&nbsp;&nbsp;&nbsp;</span><i>评估中</i></h2>
            </div>
          </header>
          <!-- Dashboard Counts Section-->
          <section class="dashboard-counts no-padding-bottom" style="padding-top:0px;">
            <div class="container-fluid">
              <div class="row bg-white has-shadow">
                <!-- Item -->
                <div class="col-xl-3 col-sm-4 stateItem">
                  <div class="item d-flex align-items-center">
                    <div class="icon bg-violet"><i class="icon-padnote"></i></div>
                    <div class="title"><span>未开始</span>
                      <div class="progress">
                        <div role="progressbar" style="width: 25%; height: 4px;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100" class="progress-bar bg-violet"></div>
                      </div>
                    </div>
                    <div class="number"><strong>25</strong></div>
                  </div>
                </div>
                
                <!-- Item -->
                <div class="col-xl-3 col-sm-4 stateItem ">
                  <div class="item d-flex align-items-center">
                    <div class="icon bg-green"><i class="icon-bill"></i></div>
                    <div class="title"><span>评估中</span>
                      <div class="progress">
                        <div role="progressbar" style="width: 40%; height: 4px;" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" class="progress-bar bg-green"></div>
                      </div>
                    </div>
                    <div class="number"><strong>40</strong></div>
                  </div>
                </div>
                
                
                
                <div class="col-xl-3 col-sm-4 stateItem">
                  <div class="item d-flex align-items-center">
                    <div class="icon bg-orange"><i class="icon-bars"></i></div>
                    <div class="title"><span>已完成</span>
                      <div class="progress">
                        <div role="progressbar" style="width: 50%; height: 4px;" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100" class="progress-bar bg-orange"></div>
                      </div>
                    </div>
                    <div class="number"><strong>50</strong></div>
                  </div>
                </div>
                 <div class="col-xl-3 col-sm-4 stateItem">
                  <div class="item d-flex align-items-center">
                    <div class="icon bg-green"><i class="icon-check"></i></div>
                    <div class="title"><span>全部项目</span>
                      <div class="progress">
                        <div role="progressbar" style="width: 50%; height: 4px;" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100" class="progress-bar bg-orange"></div>
                      </div>
                    </div>
                    <div class="number"><strong>50</strong></div>
                  </div>
                </div>
              </div>
            </div>
          </section>
          <!-- 搜索区域-->
         <section class="dashboard-counts  " style="margin-left: 13px;padding-top: 10px;">
         	<div class="input-group col-lg-4 float-left" >
              <div class="input-group-prepend">
                <button id="searchText"  data-toggle="dropdown" type="button" class="btn btn-outline-secondary dropdown-toggle" aria-expanded="false">搜索选项 <span class="caret"></span></button>
                <div class="dropdown-menu" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(0px, 38px, 0px);">
                	<a onclick="$('#searchType').val('1');$('#searchText').html($(this).text())"  class="dropdown-item">土地</a>
                	<a onclick="$('#searchType').val('2');$('#searchText').html($(this).text())"  class="dropdown-item">建筑物</a>
                  <div class="dropdown-divider"></div>
                  <a href="#" class="dropdown-item" hidden>Separated link</a>
                </div>
              </div>
              <input id="searchType" name="searchType" type="text" class="form-control" style="display: none;" value="1">
              <input id="searchContent" name="searchContent" type="text" class="form-control">
              <div class="input-group-append">
                <button id="searchBtn" type="button" class="btn btn-primary">Go!</button>
              </div>
              
            </div>
           
            <div  >
            	<span style="padding-top: 5px;font-size: 1.2em;padding-right: 5px;float: left;" ><i>时间</i> <input id="filtertime" type="checkbox"  /></span>
            	
            	<!--时间块-->
            	<div id="timezone" style="float: left;"></div>
            </div>
            
            
            
            
         </section>
          <!-- Projects Section-->
          <section class="projects no-padding-top no-padding-bottom">
            <div id="projectsArea" class="container-fluid">
            	
            	
            	
            	
            
             
              
              
            </div>
            
            <div class="project no-padding-bottom" >
            	<div class="row bg-white has-shadow">
            		<div class="left-col col-lg-12 d-flex align-items-center justify-content-between " >
            			<div class=" col-lg-10 " >
            				<div class="col-lg-1"></div>
            					<span class="col-sm-2 float-left " style="width: auto;font-size: 0.9em;margin-top: 4px;" >每页<input id="pageSize" name="pageSize" value="20" maxlength="2" style="width: 20px;margin-left: 8px;margin-right: 8px;"/>条
            					</span>
	                    <div class="CTAs float-left" style="margin-left: 8px;" >
	                    	<a id="lastPage" class="btn btn-primary  " style="background-color: #eeeeee;border: none;"><</a>
	                    	<a id="backward" class="btn btn-primary  "  style="background-color: #eeeeee;border: none;"><<</a>
	                    	<span id="pageBox" class="pageBox" >
		                    	
	                    	</span>
	                    	<a id="forward" class="btn btn-primary "  style="background-color: #eeeeee;border: none;">>></a>
	                    	<a id="nextPage" class="btn btn-primary" style="background-color: #eeeeee;border: none;">></a>
	                    </div>
	                    <span class="col-sm-2 float-left " style="width: auto;font-size: 0.9em;margin-top: 4px;" >共<i id="totalPage" name="totalPage" type="text" maxlength="2" style="width: 20px;margin-left: 8px;margin-right: 8px;">10</i>页
            					</span>
                  	</div>
            			</div>
            			
            		</div>
            	</div>
            </div>
          </section>
     
        
          <!-- Page Footer-->
          
        </div>
      </div>
    </div>
    <!-- JavaScript files-->
    <script src="vendor/jquery/jquery.min.js"></script>
    <script src="vendor/popper.js/umd/popper.min.js"> </script>
    <script src="vendor/bootstrap/js/bootstrap.min.js"></script>
    <script src="vendor/jquery.cookie/jquery.cookie.js"> </script>
    <script src="vendor/chart.js/Chart.min.js"></script>
    <script src="vendor/jquery-validation/jquery.validate.min.js"></script>
    <script src="js/charts-home.js"></script>
    <!-- Main File-->
    <script src="js/front.js"></script>
    <script type="text/javascript">
    	var total = 0;//数据总量
    	var pageNums = 0;//总页数
			var pageBarNum = 15;//每次显示分页块数量
    	var maxNow = 0;//当前已加载分页块数量
    	var pageSize = 20;//每页数据数量
    	var isFirstLoad = 1;//是否是第一次加载
    	var nowPageObj =new Object();//初始化当前已选页  默认第一页  需要在回调函数中赋初值
    	var porjectState = 3;// 0 未开始 1 评估中 2 已完成  3 全部项目  默认初始查全部项目
    	
    	
    	
    	function init(){
    		//获取url中的参数  需引入 getUrlParam.js
    		//var name=UrlParm.parm("projectid");
    		//alert(name);
    		
    		
    		
    		var clicktiems = 0;//控制起止时间是否显示
    		//显示起止时间块
    		$("#filtertime").bind("change",function(){
	    		clicktiems++;
	    		if(clicktiems%2!=0){
	    		$("#timezone").append('<span style="padding-top: 5px;font-size: 1em;padding-right: 5px;color: skyblue;"  ><i>开始时间</i></span><input id="starttime" type="date" style="margin-right: 8px;" value="2019-01-01"/>'+
		            	'<span style="padding-top: 5px;font-size: 1em;padding-right: 5px;color: skyblue;"  ><i>结束时间</i></span>'+
		            	'<input id="endtime" type="date" value="2030-01-01" />');
		       }else{
	    					$("#timezone").html("");
	    				}}
    		);
    		//绑定搜索按钮点击事件
    		$("#searchBtn").bind("click",function(){
    			var value = $("#searchContent").val();
    			var searchType = $("#searchType").val();
    			
    			doSearch(searchType, value);
    			
    		});
    		//页面头部项目状态控制
    		var pageHeader = $(".page-header");
	    	$(".stateItem").bind("click",function(){
	    		var state = $(this).find("span").text();
	    	//	pageHeader.find("span").attr("class",$(this).find("i").attr("class"));
	    		pageHeader.find("i").html($(this).find("span").text());
	    		if(state == '未开始')
	    			projectState = 0;
	    		if(state == '评估中')
	    			projectState = 1;
	    		if(state == '待审核')
	    			projectState = 2;
	    		if(state == '已完成')
	    			projectState = 3;
	    			
	    	});
	    	
	//以下为分页事件
	    	var pageBoxObj = $("#pageBox");
	    	pageSize = $("#pageSize").val();
				//加载分页页码
	    	//loadPageBar(maxNow);
	    
	    	
	    	
	    	$("#pageSize").bind('change',function(){
	    		pageSize = $(this).val();
	    		if(pageSize<1){
	    			pageSize = 20;
	    			$(this).val(20);
	    		}
	    		if(pageSize>60){
	    			pageSize = 60;
	    			$(this).val(60);
	    		}
	    		isFirstLoad = 1;//每页加载数据数改变后 需重新加载分页块
	    		resetPageSize(pageSize);
	    		
	    	});
	    	
	    	$("#lastPage").bind('click',function(){
	    		var ps = nowPageObj.text();
	    		var p = ps;
	    		aIndex = nowPageObj.index();
	    		if(pageNums==1){
	    			alert("没有更多数据了");
	    			return;
	    		}
	    		if(aIndex == 0){
	    			if(ps ==1 ){
	    				alert("当前已是首页！");
	    			}else{
	    				loadPrePageBar(ps);
	    			}
	    			
	    		}else{
	    			p--;
	    			nowPageObj.attr("style","background-color: #eeeeee;");
		    		nowPageObj = nowPageObj.prev();
		    		nowPageObj.attr("style","background-color: #33ffff;")
		    		loadPageData(nowPageObj.text());
	    		}
	    	});
	    	$("#nextPage").bind('click',function(){
	    		var p = nowPageObj.text();
	    		var pe =$("#pageBox").children().last().text();
	    		if(pageNums==1){
	    			alert("没有更多数据了");
	    			return;
	    		}
	    		if(p==pe){
	    			if(pe==pageNums){
	    				alert("当前已是末页！");
	    				return;
	    			}
	    			loadPageBar(maxNow);
	    		}else{
	    			p++;
	    			nowPageObj.attr("style","background-color: #eeeeee;");
		    		nowPageObj = nowPageObj.next();
		    		nowPageObj.attr("style","background-color: #33ffff;");
		    		loadPageData(nowPageObj.text());
	    		}
	    	});
	    	bindPageBar();
	    	//分页块向后翻页
    		$("#forward").bind("click",function(){
    			if(pageNums==1){
	    			alert("没有更多数据了");
	    			return;
	    		}
    			nextPageBar(maxNow);
    		});
    		//分页块向前
    		$("#backward").bind("click",function(){
    			if(pageNums==1){
	    			alert("没有更多数据了");
	    			return;
	    		}
    			prePageBar($("#pageBox").children().first().text());//参数为当前最小页数
    		});
    		
    		//分页数据加载完后 默认加载第一页数据
    		nowPageObj = $("#pageBox").children().first();
    		loadPageData(1);
    	}
    	init();
    	
    	
    	/*
    	 加载分页页面数据
    	 * */
    	function loadPageData(pageNow){
    		nowPageObj.attr("style","background-color: #33ffff;")
    		//清空数据
    		 $("#projectsArea").empty();
    		 if(pageNow==""){
    		 	pageNow = 1;
    		 }
    		 
    		 
    		$.ajax({
    			type:"post",
    			url:"business.spr?method=getProjectList",
    			contentType:"application/json",
              dataType: "json",
              data:JSON.stringify({
              	"pageNum":pageNow,
              	"pageSize":pageSize,
              	"state":porjectState
              }),
              success:function(data){
              	dataObj = eval("("+data+")");
              	
              	if(dataObj.result!="0000"){
                      alert(dataObj.msg);
                  }else{
                  	
                  	//处理分页数据
                  	var pageInf = dataObj.pageInf;
                  	total = pageInf.total;
                  	pageNums = pageInf.pages;
                  	$("#totalPage").html(pageNums);  
                  	$("#totaldata").html(total); 
                  	
                  	//判断是否有数据
                  	if(total == 0){
                  		showNoData();
                  	}
                  	if(pageNums==1){
                  		$("#pageBox").empty();
                  	}
                  	if(isFirstLoad == 1 && pageNums >1){
                  		isFirstLoad =0;
                  		loadPageBar(0);
                  		nowPageObj = $("#pageBox").children().first();
                  	}
                  	var projectsObj = dataObj.params;
                  	
                  	for(var i = 0;i<projectsObj.length;i++){
                  		var temp = '<div class="project" id="'+projectsObj[i].projectno+'">'+
                '<div class="row bg-white has-shadow">'+
                 ' <div class="left-col col-lg-6 d-flex align-items-center justify-content-between">'+
                  '  <div class="project-title d-flex align-items-center">'+
                   '   <div class="image has-shadow"><img src="img/project-1.jpg" alt="..." class="img-fluid"></div>'+
                    '  <div class="text">'+
                     '   <h3 class="h4">'+projectsObj[i].projectname+'</h3><small>'+projectsObj[i].manager+'</small>'+
                      '</div>'+
                   ' </div>'+
                    '<div class="project-date"><span class="hidden-sm-down"><i class="fa fa-clock-o"> &nbsp;&nbsp;&nbsp;</i>'+projectsObj[i].createtime+'</span></div>'+
                  '</div>'+
                  '<div class="right-col col-lg-6 d-flex align-items-center ">'+getIsValid(projectsObj[i].isremoved)
                  +'<div class="project-progress">'+
                      '<div class="progress">'+getProgressBar(projectsObj[i].step)+
                      '</div>'+
                  '</div>'+
                   ' <div class="col-lg-1"></div>'+
                  '  <div class="CTAs">'+getControlBtn(projectsObj[i].projectno)+
                    '</div>'+
                  '</div>'+
                '</div>'+
             ' </div>';
             $("#projectsArea").append(temp);
                  		
             		
                  	}
                  	
                  //绑定按钮事件
    							bindDelBtn();
    							bindViewBtn();
                  	
                  }
              	

              	
              },
              error:function(){
              	showNoData();
                  alert("获取失败！");

              }
    		})
    		
    		
    	}
    	//获取项目类型
    	function getIsValid(state){
    		if(state==1){
    			return '<div class="time isValid" > 拆迁 </div>';
    		}
    		if(state==0){
    			return '<div class="time isValid" > 普通 </div>';
    		}

    	}
    	//项目操作权限控制
    	//角色操作按钮控制
    	function getControlBtn(projectno){
    		
    		var temp ="";
    		if(parent.powers.has("0004")){//查看项目权限
    			temp = temp +'<a class="btn btn-primary viewProject" data-link="view_project.html?projectId='+projectno+'" style="background-color: #33ccff;border: none;">查看 </a>';
    		}
    		
         if(parent.powers.has("0008")){//删除项目权限
         	temp = temp + '<a class="btn btn-primary bg-danger delProject"   style="border: none;margin-left: 10px;">删除</a>';
         }
											
    		return temp;
    		
    	}
    	function bindViewBtn(){
    		$(".viewProject").bind("click",function(){
    			var title = "查看"+$(this).parent().parent().parent().find(".h4").html();
    			var url = $(this).attr("data-link");
    			parent.addTabs(title,url,1,null);

    			
    		});
    	}
    	
    	function getProgressBar(status){
					var bar = "";
    		switch(status){
    			

    						
    			case 5://驳回修改中  同评估中
    			case 2:
    						bar = '<div role="progressbar" style="width: 25%; height: 6px;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100" class="progress-bar bg-red"></div>';
    						break;
    						
    			case 3://评估完成待审核
    						bar = '<div role="progressbar" style="width: 50%; height: 6px;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100" class="progress-bar bg-violet"></div>';
    						break;
    			
    			case 7://审核中
    						bar = '<div role="progressbar" style="width: 75%; height: 6px;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100" class="progress-bar bg-orange"></div>';
    						break;
    						
    			case 6://完成
    						bar = '<div role="progressbar" style="width: 100%; height: 6px;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100" class="progress-bar bg-green"></div>';
    						break;
    						
    			case 1://已提交 保存状态 还未评估完成
    			case 4://审核驳回待修改 同未开始
    			default:
    						bar = '<div role="progressbar" style="width: 100%; height: 6px;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100" class="progress-bar bg-gray"></div>';
    						break;
    		}
    		return bar;
    	}
    		
    //加载分页块
    	function loadPageBar(pageNum){
    		var content = "";
    		var t = pageNum+pageBarNum;
    		
    		if(t>pageNums){
    			
    			endNum = pageNums;
    			maxNow = pageNums;//游标移至最后一页
    		}else{
    			endNum = t;
    			maxNow = maxNow + pageBarNum;
    		}
    		$("#pageBox").html("");
    		for(var i = pageNum+1;i <= endNum;i++){
    			content = content+'<a id="pg'+i+'" class="btn btn-sm" style="background-color: #eeeeee;border: none;margin-left: 4px;">'+i+'</a>';
    		}
    		
    		$("#pageBox").append(content);
    		bindPageBar();//元素删除后需要重新绑定
    		
    	}
    	
    	function loadPrePageBar(minNow){
    		var content = "";
    		var startNum = 1;
    		var t = minNow-pageBarNum;
    		if(pageNums==1)
    		{
    			alert("没有更多数据了！");
    			return;
    		}
    		
    		if(t >= 1){
    			startNum = t;
    		}else{
    			alert("没有更多数据了！");
    			return;
    		}
    		$("#pageBox").html("");
    		for(var i = startNum;i <= minNow-1;i++){
    			content = content+'<a id="pg'+i+'" class="btn btn-sm" style="background-color: #eeeeee;border: none;margin-left: 4px;">'+i+'</a>';

    		}
    		
    		$("#pageBox").append(content);
    		bindPageBar();//元素删除后需要重新绑定
    		//分页数据加载完后 默认加载第一页数据
    		nowPageObj = $("#pageBox").children().first();
    		
    		loadPageData(nowPageObj.text());
    		
    	}
    	
    	
    	
    	function bindPageBar(){
    		//分页块点击事件
    		$(".pageBox a").unbind("click");
	    	$(".pageBox a").bind("click",function(){
	    		nowPageObj.attr("style","background-color: #eeeeee;");
	    		nowPageObj = $(this);
	    		nowPageObj.attr("style","background-color: #33ffff;");
	    		loadPageData(nowPageObj.text());
	    	});
    	}
    	
    	function nextPageBar(){
    		if(pageNums==1)
    		{
    			alert("没有更多数据了！");
    			return;
    		}
    		if(maxNow < pageNums){
    			loadPageBar(maxNow);
    		}else{
    			alert("没有更多数据了！");
    		}
    	}
    	function prePageBar(minNow){
    		if(pageNums==1)
    		{
    			alert("没有更多数据了！");
    			return;
    		}
    		if(minNow==1){
    			alert("没有更多数据了！")
    		}else{
    			loadPrePageBar(minNow);
    		}
    	}
    	//当分页数量变化时  重新加载事件
    	function resetPageSize(Size){
    		pageSize = Size;
    		loadPageData(1)
    		
    	}
    	
    	function showNoData(){
    		
    		var temp = 
    		'<section id="nodata" class="dashboard-counts no-padding-bottom row"  style="margin-bottom: 20px; ">'+
	            	'<div class="container-fluid">'+
	              	'<div class="row bg-white has-shadow " >'+
	              '	<h3 class="h3" style="color: gainsboro;margin-left: 40%;">没有更多数据了。。。</h3>'+
	              	
	              '	</div> </div></section>';
	       $("#projectsArea").append(temp);
    	}
    
    	/*
    	 搜索事件
    	 * */
    	function doSearch(searchType, value){
    		var starttime = $("#starttime").val();
    		var endTime = $("#endtime").val();
    			if(starttime ==undefined){
    				starttime = 0;
    				endTime = 0;
    			}
    			if(value == ""){
    				return;
    			}
    			alert("go search "+searchType+value+starttime+endTime);
    			
    	}
    	
    	function bindDelBtn(){
    		$(".delProject").bind("click",function(){
    			
    			var projectname = $(this).parent().parent().parent().find(".h4").html();

    			if(!confirm("确认要删除项目  "+projectname+"  吗")){
    				return;
    			}
    			
    			var projectId = $(this).parent().parent().parent().parent().attr("id");
    				$.ajax({
    			type:"get",
    			url:"business.spr?method=delProject",
    			contentType:"application/json",
              dataType: "json",
              data:{
              	"projectId":projectId
              },
              success:function(data){
              	dataObj = eval("("+data+")");
              	
              	if(dataObj.result!="0000"){
                      alert(dataObj.msg);
                  }else{
                  	alert("项目"+projectname+"删除成功！");
                  	$("#"+projectId).remove();
                  	
                  }
                },
                error:function(){
                	 alert("删除失败！");
                }
              });
    			
    		});
    		
    	}
    	
    </script>
  </body>
</html>